﻿
Imports System.IO.File
Public Class FormIPonline

    Private Sub FormIPonline_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Local_IP.Text = LineIP_Date(0)
        Local_com.Text = LineIP_Date(1)
        Long_rangeIP.Text = LineIP_Date(2)
        Long_rangeCom.Text = LineIP_Date(3)

        Timer1.Enabled = True

        If Bfalge = False Then
            Local_con.Text = "连接失败"
        Else
            Local_con.Text = "连接打开"
        End If

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Local_con.Text = "连接打开" Then
            Local_con.Text = "连接打开"
            MsgBox("连接已打开")
            Return
        End If
        FrmMain.InitTcpSever2()
        If Bfalge = False Then
            Local_con.Text = "连接失败"
        Else
            Local_con.Text = "连接打开"
        End If
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Accept_Date.Text = SeverDate
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click     '清空数据
        SeverDate = ""
        Accept_Date.Text = ""
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

        Me.Close()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Globalfunc.SendDataNORePly(Send_date.Text, Long_rangeIP.Text, Long_rangeCom.Text, "UTF8")

    End Sub

    Private Sub FormIPonline_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        Timer1.Enabled = False
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click    '保持数据
        Dim PonLJ As Integer = FreeFile()
        Try

            Dim LJIP_Date As String = ""
            FileOpen(PonLJ, gProDataPath & "\PonLineIP.txt", OpenMode.Random)

            LineIP_Date(0) = Local_IP.Text
            LineIP_Date(1) = Local_com.Text
            LineIP_Date(2) = Long_rangeIP.Text
            LineIP_Date(3) = Long_rangeCom.Text

            Dim i As Integer
            For i = 0 To 3
                LJIP_Date += LineIP_Date(i).ToString & ","
            Next
            FilePut(PonLJ, LJIP_Date)
            FileClose(PonLJ)
            MsgBox("保存成功")
        Catch ex As Exception
            FileClose(PonLJ)
            MsgBox("保存失败:" & ex.Message.ToString & ex.StackTrace.ToString)
        End Try
    End Sub
End Class